package com.adulcimer.core.config;

import com.adulcimer.core.filter.LoginFilter;
import com.adulcimer.models.entity.service.UserService;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Simon
 * @create 2025/2/21
 * @Description
 **/

@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<LoginFilter> loggingFilter(UserService userService) {
        FilterRegistrationBean<LoginFilter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(new LoginFilter(userService));
        registrationBean.setOrder(1);
        registrationBean.addUrlPatterns("/api/account/**");  // 配置拦截路径
        return registrationBean;
    }
}